package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;

import java.util.*;

/**
 * 描述：每个集合都可以通过stream
 */
public class CollectionToStream {
    public static void main(String[] args) {
        List<Bubble> bubbles = Arrays.asList(new Bubble(1), new Bubble(2), new Bubble(3));
        System.out.println(bubbles.stream().mapToInt(o -> o.i).sum());

        Set<String> w = new HashSet<>(Arrays.asList("It is a wonderful day for pie!".split(" ")));
        w.stream().map(o -> o + " ").forEach(System.out::print);

        System.out.println();

        Map<String, Double> m = new HashMap<>();
        m.put("pi", 3.1415926);
        m.put("e", 2.718);
        m.put("phi", 1.618);
        m.entrySet().stream().map(o -> o.getKey() + ":" + o.getValue()).forEach(System.out::println);
    }
}
